<template>
	<view class="container">
		<u-tabs class="tabs" :list="tablist" :is-scroll="true" :current="current" @change="change" active-color="#AB61FF"></u-tabs>
		
		<view class="u-flex u-row-center u-m-50" v-if="list.length == 0" style="flex-direction: column;">
			<image style="width:300rpx;height:300rpx;" mode="widthFix" src="../../static/img/nog.png"></image>
			<text style="color:#ccc">暂无记录</text>
		</view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="handleClickItem(item)" style="background:url(../../static/mine/jy.png) #fff no-repeat bottom right;">
				<view class="left">
					<view class="item-cell">
						<view class="title">需要</view>
						<view class="value u-line-1">{{item.ineed}}</view>
					</view>
					<view class="item-cell">
						<view class="title">意向</view>
						<view class="value u-line-1">{{item.imean}}</view>
					</view>
					<view class="item-cell">
						<view class="text u-line-1">{{item.userName}}</view>
					</view>
				</view>
			</view>
			<u-toast ref="uToast" />
			<u-loadmore class="u-m-t-40" v-if="list.length == 3" :status="loadStatus" bg-color="#F5F5F9"></u-loadmore>
		</view>
	</view>
</template>

<script>
	import classifyData from "@/common/classify.data.js";
	export default {
		data() {
			return {
				tablist: [],
				current: 0,
				tabbar: classifyData,
				list:[],
				form:{
					pageNum:1,
					pageSize:10,
					type:'zhtd'
				},
				loadStatus: 'loadmore'
			};
		},
		onPullDownRefresh: function() {
			this.form.pageNum = 1;
			this.getList();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom:function(e){
			// 此tab为空数据
			this.form.pageNum += 1;
			this.loadStatus= "loading";
			this.getList(this.form.pageNum);
		},
		onLoad() {
			let that = this;
			this.tabbar.forEach(function(item){
				that.tablist.push(item)
			})
			console.log(that.tablist)
			this.getList();
		},
		methods: {
			handleClickItem(item){
				let type =this.tabbar[this.current].type;
				uni.navigateTo({
					url:'/pages/follow/teamDetail?type='+type+'&row='+encodeURIComponent(JSON.stringify(item))
				})
			},
			async getList(page){
				let data = await this.$apis.businessFootprints(this.form);
				if(data.data.length<this.form.pageSize){
					this.loadStatus = "nomore";
				}
				if(page){
					this.list =this.list.concat(data.data);
				}else{
					this.list = data.data;
				}
			},
			change(index) {
				this.current = index;
				this.form.pageNum = 1;
				this.form.pageSize = 10;
				this.form.type = this.tablist[index].type;
				this.getList();
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #F5F5F9;
	}
	.container{
		.tabs{
		}
		.list{
			width: 100%;
			padding: 20upx;
			.item{
				width: 100%;
				background: #fff;
				padding: 28upx;
				border-radius: 20upx;
				display: flex;
				justify-content: space-between;
				background-size:100% auto;
				height: 206upx;
				margin-bottom: 20upx;
				.right{
					display: flex;
					flex-direction: column-reverse;
					image{
						width: 105upx;
						height: 96upx;
					}
				}
				.left{
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					.item-cell{
						display: flex;
						justify-content: space-between;
						.title{
							width:100rpx;
							line-height: 30upx;
							height: 30upx;
							color: #9DA2B0;
							font-size: 30upx;
						}
						.value{
							flex:1;
							width:500rpx;
							line-height: 30upx;
							height: 30upx;
							color: #0D1D36;
							font-size: 30upx;
							margin-left: 30upx;
						}
						.text{
							color: #4B9CFF;
							font-size: 30upx;
						}
					}
				}
			}
		}
	}
</style>
